#ifndef GAME_H
#define GAME_H

#include <QWidget>
#include <QPainter>
#include <QMouseEvent>
#include <QRadioButton>
#include <QEventLoop>
#include <QTimer>
#include "chessman.h"
#include "enums.h"

namespace Ui {
class game;
}

class game : public QWidget
{
    Q_OBJECT

public:
    explicit game(QWidget *parent = nullptr);
    ~game();
    const int WIDTH=40;
    const int LINES=19;             //19*19
    const int SIZE=LINES+1;
    const int chessmanoffset=2*WIDTH;
    const float selectXoffset=13.7;
    const int selectY=253;
    const int Start=20;
    const int yChessman=260;
    chessman* table = nullptr;
    void initui();
    void initgame();
    void initpainter();
    void paintEvent(QPaintEvent *);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent* event);
    void print(int x,int y);
    bool erase(int x,int y);
    int iswin();
    chessman get(int x,int y);
    int put(int x,int y,chessmanType type);
    void delay_msec(unsigned int msec);
    void msg(QString q);
    void clearmsg();
    int step=0;
    std::vector<int> stepX;
    std::vector<int> stepY;
    int chessPlayer;
    int gamemode=started;
    void setStep(int step);

private slots:
    void on_pushButton_3_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_clicked();
    void restartgame(bool changeOffensiveMovePlayer);

private:
    Ui::game *ui;
    QPainter *painter;
    bool drawChess = false;
    int mouseX,mouseY;
    int winner=none_win;
    int chessmanNum=0;
    int putSucess;

};

#endif // GAME_H
